package me.zhengjie.weixin;

import lombok.Data;
import org.apache.hc.core5.http.ParseException;

import java.io.IOException;
import java.io.Serializable;
import java.util.Map;

public abstract class WxTemplateAbstract {

//    protected Map<String, Data> dataMap;

    abstract String getTemplateId();

    abstract Map<String, Data> getData();

    public int sendMsg(String touser,String url) throws IOException, ParseException {
        return WxTemplateUtil.sendTemplateMsg(touser,this,url);
    }

    public int sendMsg(String touser) throws IOException, ParseException {
        return WxTemplateUtil.sendTemplateMsg(touser,this);
    }

    @lombok.Data
    static class Data implements Serializable {

        private static final long serialVersionUID = 1L;

        String value;
        String color;
        private Data(){}

        private Data(String value,String color){
            this.value = value;
            this.color = color;
        }
        private Data(String value){
            this.value = value;
            this.color = "#000000";
        }
        public static Data creat(String value,String color){
            return new Data(value,color);
        }

        public static Data creat(String value){
            return new Data(value);
        }

    }
}
